package IC.lir;


import java.util.Map;
import java.util.HashMap;
import IC.lir.Instrunction.Label;

public class LabelGenerator 
{
	private static final String LabelPrefix = "_Label__";
	private Map<String, Integer> _map = new HashMap<String, Integer>();
	
	public void Reset() { _map.clear(); }
	
	public Label GenerateLabel(String prefix)
	{
		Integer searched = _map.get(prefix);
		if (searched == null)
			searched = 0;
		
		_map.put(prefix, searched + 1);
		
		return new Label(LabelPrefix + prefix + "_" + searched);
	}
	
	public Label GenerateLabel()
	{
		return GenerateLabel("Label");
	}
}
